<template>
    <div>
        <ul class="mui-table-view">
            <router-link 
             class="mui-table-view-cell mui-media"
             v-for="item in newsList"
             :key="item.id" 
             tag="li" 
             :to="'/home/newLsit/newDetail/'+item.id">
                <a href="javascript:;">
                    <img class="mui-media-object mui-pull-left" :src="'http://t2.hddhhn.com/uploads/tu/201612/98/st94.png'">
                    <div class="mui-media-body">
                        <span>{{ item.title }}</span>
                        <p class='mui-ellipsis'>
                            <span>{{ item.add_time |dataFormat }}</span>
                            <span>点击：{{ item.click }}次</span>
                        </p>
                    </div>
                </a>
            </router-link>
        </ul>
    </div>
</template>

<script>
import Toast from 'mint-ui'

export default {
    data () {
        return {
            newsList:[]
        }
    },
    created() {
        this.getNewsList()
    },
    methods:{
        getNewsList () {
            this.$http.get('api/getnewslist').then(res => {
                // console.log(res.body.message)
                if(res.body.status === 0) {
                    this.newsList = res.body.message
                } else {
                    Toast('获取新闻资讯失败')
                }
            })
        }
    }
};
</script>

<style lang="scss" scoped>
.mui-media-body {
  span {
    font-size: 13px;
    font-weight: bold;
  }
  .mui-ellipsis {
    font-size: 12px;
    color: #226aff;
    display: flex;
    justify-content: space-between;
  }
}
</style>

